﻿namespace Website_Gateway.Services.Handler
{
    public class IgnoreSslErrorsHandler : DelegatingHandler
    {
        protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            // 创建自定义的HTTP客户端处理器，跳过SSL证书验证
            var handler = new HttpClientHandler
            {
                ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true
            };

            using (var client = new HttpClient(handler))
            {
                return await client.SendAsync(request, cancellationToken);
            }
        }
    }
}
